import { Controller, Get, Post, Body, Patch, Param, Delete, HttpCode, Query, UseGuards } from '@nestjs/common';
import { SetingService } from './seting.service';
import { CreateSetingDto, GetSetingDto, UpdateSetingDto } from './dto/seting.dto';
import { ApiBearerAuth, ApiBody, ApiOperation, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';
import { AuthGuard } from '@nestjs/passport';
import { IdDto } from 'src/common/dto/dto';
import { SetingResult } from './entities/seting.entity';

@ApiBearerAuth() // swagger文档设置token
@ApiTags('系统设置')
@Controller('admin/seting')
export class SetingController {
  constructor(private readonly setingService: SetingService) { }


  /** 系统设置 */
  @HttpCode(200)
  @Get('/getSeting')
  @ApiResponse({
    status: 200,
    description: '系统设置列表',
    type: SetingResult,
  })
  @ApiOperation({
    tags: ['获取系统设置'],
    summary: '获取系统设置',
    operationId: 'getSeting',
  })
  @UseGuards(AuthGuard('jwt')) // 自定义守卫
  getSeting(@Query() params: GetSetingDto) {
    return this.setingService.getSeting(params);
  }
  @HttpCode(200)
  @Post('/createSeting')
  @ApiBody({
    description: '创建系统设置',
    type: CreateSetingDto,
  })
  @ApiOperation({
    summary: '创建系统设置',
    operationId: 'createSeting',
  })
  @UseGuards(AuthGuard('jwt')) // 自定义守卫
  async createSeting(@Body() body: CreateSetingDto) {
    return this.setingService.createSeting(body);
  }
  @HttpCode(200)
  @Post('/updateSeting')
  @ApiBody({
    description: '更新系统设置信息',
    type: UpdateSetingDto,
  })
  @ApiOperation({
    summary: '更新系统设置信息',
    operationId: 'updateSeting',
  })
  @UseGuards(AuthGuard('jwt')) // 自定义守卫
  async updateSeting(@Body() body: UpdateSetingDto) {
    return this.setingService.updateSeting(body);
  }
  @HttpCode(200)
  @Post('/deleteSeting')
  @ApiBody({
    description: '删除系统设置',
    type: IdDto,
  })
  @ApiOperation({
    summary: '删除系统设置',
    operationId: 'deleteSeting',
  })
  @UseGuards(AuthGuard('jwt')) // 自定义守卫
  async deleteSeting(@Body() body: IdDto) {
    return this.setingService.deleteSeting(body);
  }
}
